package pl.edu.agh.sius.controller;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import javax.faces.model.SelectItem;

import pl.edu.agh.sius.utils.FacesHelper;

public class FirstChoiceBB {

	public static final Map<Concern, String> concernTitles =
		new HashMap<Concern, String>();

	static {
		concernTitles.put(Concern.ESTATE_SPLIT, "Podanie o podział nieruchomości");
		concernTitles.put(Concern.TEMPORAL_BENEFIT, "Wniosek o zasilek tymczasowy");
		concernTitles.put(Concern.WASTE_TRANSPORT, "Wniosek o transport odpadów");
	}
	
	public enum Concern {
		WASTE_TRANSPORT, TEMPORAL_BENEFIT, ESTATE_SPLIT
	}

	public List<SelectItem> getConcerns() {
		List<SelectItem> items = new LinkedList<SelectItem>();
		for (Concern c : Concern.values()) {
			items.add(new SelectItem(c,concernTitles.get(c)));
		}
		return items;
	}

	private Concern concern;

	public Concern getConcern() {
		return concern;
	}

	public void setConcern(Concern concern) {
		this.concern = concern;
	}

	public String go() {
		if (concern == null) {
			FacesHelper.addMessage("Błąd w nawigacji - sprawa nie ustalona.",
					null);
			return null;
		}
		try {
			FacesHelper.activateController(concern);
		} catch (Exception e) {
			FacesHelper.addMessage(e.getMessage(), null);
			return null;
		}
		System.out.println(concern.toString());
		if (Concern.ESTATE_SPLIT.equals(concern)) {
			return "concern1";
		}
		if (Concern.TEMPORAL_BENEFIT.equals(concern)) {
			return "concern2";
		}
		if (Concern.WASTE_TRANSPORT.equals(concern)) {
			return "concern3";
		} else {
			return null;
		}
	}

}
